/*
 * @Author:   LiuNing - liuning_apple@126.com
 * @Date:     2020年11月11日15:15:58
 */
import instance from '@/utils/axios'

// 获取地图点位
const base = 'billboard/'
const user = 'bus/billboard/'

export const getZone = () => {
  return instance({
    url: 'get-zone',
    method: 'post'
  })
}

export const exportFile = () => {
  return instance({
    url: `${base}export`,
    method: 'post'
  })
}

// 关键词查询
export const getPointByKeyword = (name) => {
  return instance({
    url: `${base}prepoint`,
    method: 'post',
    data: {
      name
    }
  })
}

export const getUserInfo = (random) => {
  return instance({
    url: `user/info?random=${random}`,
    method: 'post'
  })
}

export const uploadWeekFile = (data) => {
  return instance({
    url: 'user/weekreport-upload',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export const uploadWeekSrc = (data) => {
  return instance({
    url: 'user/weekreport-save',
    method: 'post',
    data
  })
}

// 获取点位
export const getPointList = (data = {}) => {
  return instance({
    loading: true,
    url: `${base}list`,
    method: 'post',
    data
  })
}

export const getPointTable = (data = {}) => {
  return instance({
    url: `${base}pages`,
    method: 'post',
    data
  })
}

// 获取点位详情
export const getPointInfo = (id) => {
  return instance({
    url: '/bus/user/car/show',
    method: 'post',
    data: {
      id
    }
  })
}

// 获取点位详情
export const getPointDetail = (data = {}) => {
  return instance({
    url: `${base}show`,
    method: 'post',
    data
  })
}

export const getSearch = (data = {}) => {
  return instance({
    url: `${base}search`,
    method: 'post',
    data
  })
}

// 添加到点位图列表
export const setMemberLists = (data) => {
  return instance({
    url: `${user}save`,
    method: 'post',
    data
  })
}

// 获取个人中心点位
export const getMemberLists = (data) => {
  return instance({
    url: `${user}index`,
    method: 'post',
    data
  })
}

// 个人中心点位改名
export const setMemberName = (data) => {
  return instance({
    url: `${user}update`,
    method: 'post',
    data
  })
}

// 个人中心删除点位
export const delMemberLists = (data) => {
  return instance({
    url: `${user}del`,
    method: 'post',
    data
  })
}

// 预约点位
export const setBooking = (data) => {
  return instance({
    url: 'bus/booking/add',
    method: 'post',
    data
  })
}

// 获取已选列表
export const getCheckList = () => {
  return instance({
    url: 'bus/favorite/index',
    method: 'post'
  })
}

// 删除已选点位
export const delCheckList = (data) => {
  return instance({
    url: 'bus/favorite/delete',
    method: 'post',
    data
  })
}

// 一键清空
export const clearCheckList = () => {
  return instance({
    url: 'bus/favorite/reset',
    method: 'post'
  })
}

// 批量新增点位
export const addCheckList = (data) => {
  return instance({
    url: 'bus/favorite/batch-save',
    method: 'post',
    data
  })
}

// 单独新增点位
export const addCheckListSingle = (data) => {
  return instance({
    url: 'bus/favorite/save',
    method: 'post',
    data
  })
}

// 获取分类
export const getCategory = () => {
  return instance({
    url: 'category/list',
    method: 'get'
  })
}

// 获取点位总数
export const getPointNums = () => {
  return instance({
    url: `${base}total-num`,
    method: 'post'
  })
}
